package com.huntech.data.util;

public class ResultUtil {
    public static <T> Result<T> success(Object object) {
        Result result = new Result();
        result.setCode(200);
        result.setMessage("成功");
        result.setData(object);
        return result;
    }

    public static <T> Result<T> success(Object object ,Integer total) {
        Result result = new Result();
        result.setCode(200);
        result.setMessage("成功");
        result.setTotal(total);
        result.setData(object);
        return result;
    }

    public static <T> Result<T> success() {

        return success(null);
    }

    public static <T> Result<T> success(Object object ,String msg ,Integer code) {
        Result result = new Result();
        result.setCode(code);
        result.setMessage(msg);
        result.setData(object);
        return result;
    }


    public static <T> Result<T> error(Integer code, String msg) {
        Result result = new Result();
        result.setCode(code);
        result.setMessage(msg);
        return result;
    }

    public static <T> Result<T> error(String code, String msg) {
        Result result = new Result();
        result.setCode(Integer.parseInt(code));
        result.setMessage(msg);
        return result;
    }
}
